<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="时间">
        <el-date-picker :editable="false" :clearable="false" style="width: 140px;"
                        v-model="queryParams.monthTime"
                        type="month"
                        value-format="yyyy-MM"
                        placeholder="选择时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="reportTj">统计</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :stripe="true" :data="reportList" :max-height="tabHt">
      <el-table-column width="180" fixed :label="`监测站点`" align="center" prop="pointName" />
      <el-table-column v-for="obj in headObj" :label="obj.title" :key="obj.key" align="center">
        <el-table-column width="70" :label="`到报数`" align="center" :prop="`${obj.key}`" >

          <template v-slot="scope">
            <span v-if="scope.row[`${obj.key}`]" style="color:#00ff00;">{{scope.row[`${obj.key}`]}}</span>
            <span v-else>0</span>
          </template>

        </el-table-column>
        <el-table-column width="70" :label="`到报率`" align="center" :prop="`${obj.key}dbl`" >

          <template v-slot="scope">
            <span v-if="scope.row[`${obj.key}`]" >{{(scope.row[`${obj.key}`]/scope.row[`dayNum`]*100).toFixed(1)}}%</span>
            <span v-else >0%</span>
          </template>

        </el-table-column>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
  import { querySticsReportMap } from "@/api/basic/dataMsgLog";

  export default {
    name: "SticsReport",
    components: {
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        headObj:[{'title':'11月01日01时','key':'key110101'},{'title':'11月01日02时','key':'key110102'}],
        reportList:[{'pointName':'福州站','key110101zx':'31','key110101lx':'29'},{'pointName':'厦门站','key110101zx':'21','key110101lx':'39'}],
        // 日期范围
        dateRange: "",
        // 查询参数
        queryParams: {
          monthTime:null,
        },
      };
    },
    computed: {
      tabHt(){
        return this.$store.state.app.tableHeight.ht
      }
    },
    mounted() {
      let nowDate = new Date();
      let byear = nowDate.getFullYear();
      let bmonth = nowDate.getMonth() + 1;
      this.queryParams.monthTime = `${byear}-${bmonth}`;
    },
    created() {
      this.$nextTick(() => {
        this.reportTj();
      });

    },
    methods: {
      /** 查询监测站点联网记录列表 */
      reportTj() {
        this.loading = true;
        querySticsReportMap(this.queryParams).then(response => {
          this.headObj = response.data.headObj;
          this.reportList = response.data.reportList;
          this.loading = false;
        });
      },
    }
  };
</script>
